package com.cyandpos.pad.activity.attachfunction;

import android.graphics.Rect;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;

import com.cyandpos.pad.utils.CommonUtils;


//设置Item间隔
public class SpaceItemDecoration extends RecyclerView.ItemDecoration {
    private int mSpace;
    private int itemsize;

    /**
     * @param space 传入的值，其单位视为dp
     */
    public SpaceItemDecoration(int space) {
        this.mSpace = CommonUtils.px2dip(space);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
//        int itemCount = itemsize;
        int pos = parent.getChildAdapterPosition(view);
//        Log.d("derek", "itemCount>>" + itemCount + ";Position>>" + pos);

        outRect.left = 0;
        outRect.right = 0;
        outRect.bottom = 0;
        outRect.top = mSpace;
    }
}